summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/vendors/[id]/info/rfq-history/page.tsx
blob: 1d2f618cd8fb11e593bcce8e8b1c982de30358d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Separator } from "@/components/ui/separator"
import { getRfqHistory } from "@/lib/vendors/service"
import { type SearchParams } from "@/types/table"
import { getValidFilters } from "@/lib/data-table"
import { searchParamsRfqHistoryCache } from "@/lib/vendors/validations"
import { VendorRfqHistoryTable } from "@/lib/vendors/rfq-history-table/rfq-history-table"

interface IndexPageProps {
  // Next.js 13 App Router에서 기본으로 주어지는 객체들
  params: {
    lng: string
    id: string
  }
  searchParams: Promise<SearchParams>
}

export default async function RfqHistoryPage(props: IndexPageProps) {
  const resolvedParams = await props.params
  const lng = resolvedParams.lng
  const id = resolvedParams.id

  const idAsNumber = Number(id)

  // 2) SearchParams 파싱 (Zod)
  //    - "filters", "page", "perPage", "sort" 등 contact 전용 컬럼
  const searchParams = await props.searchParams
  const search = searchParamsRfqHistoryCache.parse(searchParams)
  const validFilters = getValidFilters(search.filters)

  const promises = Promise.all([
    getRfqHistory({
      ...search,
      filters: validFilters,
    },
    idAsNumber)
  ])

  // 4) 렌더링
  return (
    <div className="space-y-6">
      <div>
        <h3 className="text-lg font-medium">
          RFQ History
        </h3>
        <p className="text-sm text-muted-foreground">
          벤더의 RFQ 참여 이력을 확인할 수 있습니다.
        </p>
      </div>
      <Separator />
      <div>
        <VendorRfqHistoryTable promises={promises} />
      </div>
    </div>
  )
}